package com.bds.btcdc;

import com.bds.btcdc.handler.*;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.messaging.converter.MappingJackson2MessageConverter;
import org.springframework.web.socket.client.WebSocketClient;
import org.springframework.web.socket.client.standard.StandardWebSocketClient;
import org.springframework.web.socket.messaging.WebSocketStompClient;

import com.bds.btcdc.util.Const;

public class AppStartupList implements ApplicationListener<ContextRefreshedEvent> {

	@Override
	public void onApplicationEvent(ContextRefreshedEvent arg0) {

		WebSocketClient client = new StandardWebSocketClient();

		WebSocketStompClient stompClient = new WebSocketStompClient(client);

		stompClient.setMessageConverter(new MappingJackson2MessageConverter());

		StompSessionHandler sessionHandler = new StompSessionHandler();
		stompClient.connect(Const.WS_URL, sessionHandler);

		OKCoinSessionHandler okcoiinHandler = new OKCoinSessionHandler();
		stompClient.connect(Const.WS_URL, okcoiinHandler);

		OKEXSessionHandler okexHandler = new OKEXSessionHandler();
		stompClient.connect(Const.WS_URL, okexHandler);

		ZBSessionHandler zbHandler = new ZBSessionHandler();
		stompClient.connect(Const.WS_URL, zbHandler);

		HUOBISessionHandler huobiHandler=new HUOBISessionHandler();
		stompClient.connect(Const.WS_URL, huobiHandler);

	}

}
